<!DOCTYPE html>
<html>
  <head>
    <title>Chaskiq App</title>
    <%= csrf_meta_tags %>
    <%= csp_meta_tag %>
    <meta name="chaskiq-host" content="<%= ENV['HOST'] %>"/>
    <meta content='True' name='HandheldFriendly'>
    <meta content='320' name='MobileOptimized'>
    <!--<meta content='width=device-width, initial-scale=1' name='viewport'>
    <meta content='width=device-width, initial-scale=1' media='(device-height: 568px)' name='viewport'>
    -->
    <meta
      name="viewport"
      content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no"
    >

    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.10/css/all.css" integrity="sha384-+d0P83n9kaQMCwj8F4RJB66tzIwOKmrdb46+porD/OvrJ+37WqIM7UoBtwHO6Nlg" crossorigin="anonymous">
    <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
    <%= javascript_pack_tag 'application' %>
    <%= stylesheet_pack_tag "application" %> 

    <link href="https://fonts.googleapis.com/css?family=PT+Sans|Roboto+Mono&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,300i,400,400i,500,500i,600,600i,700,700i&amp;subset=latin-ext">
  
  </head>

  <body>
    <div class="page" id="main-page">
    </div>


    <% if @app.article_settings && @app.article_settings.google_code %>

      <script 
        key="3"
        async 
        src="https://www.googletagmanager.com/gtag/js?id=<%= @app.article_settings.google_code %>"
      >
      </script>

      <script>
        window.dataLayer = window.dataLayer || [];
        function gtag(){dataLayer.push(arguments);}
        gtag('js', new Date());
        gtag('config', "<%= @app.article_settings.google_code %>" );
      </script>
    <% end %>

    <script>
      (function(d,t) {
        var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
        g.src="<%=@h[:http] +request.env["HTTP_HOST"]%>/embed.js"
        s.parentNode.insertBefore(g,s);
        g.onload=function(){
          window.chaskiqMessenger = new window.ChaskiqMessengerEncrypted({
            domain: '<%=@h[:http] +request.env["HTTP_HOST"]%>',
            ws:  '<%= Rails.application.config.action_cable.url %>',
            //lang: "<%= @lang %>",
            app_id: "<%= @app.key %>"
          })
        }
      })(document,"script");
    </script>



  </body>
</html>
